package com.miaoshapro.exception;

import com.miaoshapro.error.CommonError;

// 包装器业务异常实现
public class CommonException extends Exception implements CommonError {

    private CommonError commonError;

    public CommonException(CommonError commonError) {
        super();
        this.commonError = commonError;
    }

    // 通过自定义errorMsg的方式构造异常
    public CommonException(CommonError commonError, String errorMsg) {
        super();
        this.commonError = commonError;
        this.commonError.setErrorMsg(errorMsg);
    }

    @Override
    public Integer getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMsg() {
        return this.commonError.getErrorMsg();
    }

    @Override
    public void setErrorMsg(String errorMsg) {
        this.commonError.setErrorMsg(errorMsg);
    }
}
